﻿// Author:				    Joe Audette
// Created:			        2010-05-11
// Last Modified:		    2010-08-10
// 
// The use and distribution terms for this software are covered by the 
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.TXT at the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by 
// the terms of this license.
//
// You must not remove this notice, or any other, from this software.

using System;
using System.Collections;
using mojoPortal.Web.Framework;

namespace ud_ImageSlideShow
{
    /// <summary>
    /// encapsulates the feature instance configuration loaded from module settings into a more friendly object
    /// </summary>
    public class ImageSlideShowConfiguration
    {
        public ImageSlideShowConfiguration()
        { }

        public ImageSlideShowConfiguration(Hashtable settings)
        {
            LoadSettings(settings);
        }

        private void LoadSettings(Hashtable settings)
        {
            if (settings == null) { throw new ArgumentException("must pass in a hashtable of settings"); }

            if (settings.Contains("CustomCssClassSetting"))
            {
                customCssClass = settings["CustomCssClassSetting"].ToString();
            }
            if (settings.Contains("CustomCssCarouselSetting"))
            {
                customCssCarousel = settings["CustomCssCarouselSetting"].ToString();
            }
            showImageWrapSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowImageWrapSetting",
                                                                   showImageWrapSetting);
            noInvidualModule = WebUtils.ParseBoolFromHashtable(settings, "NoInvidualModuleSetting",
                                                                   noInvidualModule);
            useVerticalSetting = WebUtils.ParseBoolFromHashtable(settings, "UseVerticalSetting",
                                                                 useVerticalSetting);
            useRightToLeftSetting = WebUtils.ParseBoolFromHashtable(settings, "UseRightToLeftSetting",
                                                                    useRightToLeftSetting);
            startSetting = WebUtils.ParseInt32FromHashtable(settings, "StartSetting",
                                                            startSetting);
            offsetSetting = WebUtils.ParseInt32FromHashtable(settings, "OffsetSetting",
                                                             offsetSetting);
            sizeSetting = WebUtils.ParseInt32FromHashtable(settings, "SizeSetting",
                                                           sizeSetting);
            scrollItemSetting = WebUtils.ParseInt32FromHashtable(settings, "ScrollItemSetting",
                                                                 scrollItemSetting);
            animationSetting = WebUtils.ParseInt32FromHashtable(settings, "AnimationSetting",
                                                                animationSetting);
            if (settings.Contains("EasingSetting"))
            {
                easingSetting = settings["EasingSetting"].ToString();
            }
            autoSetting = WebUtils.ParseInt32FromHashtable(settings, "AutoSetting",
                                                           autoSetting);
            if (settings.Contains("WrapSetting"))
            {
                wrapSetting = settings["WrapSetting"].ToString();
            }
            if (settings.Contains("ItemVisibleInCallbackSetting"))
            {
                itemVisibleInCallbackSetting = settings["ItemVisibleInCallbackSetting"].ToString();
            }
            if (settings.Contains("ItemVisibleOutCallbackSetting"))
            {
                itemVisibleOutCallbackSetting = settings["ItemVisibleOutCallbackSetting"].ToString();
            }
            if (settings.Contains("ModuleLoaderSetting")) { moduleLoader = settings["ModuleLoaderSetting"].ToString(); }
        }

        private string customCssClass = string.Empty;
        public string CustomCssClass { get { return customCssClass; } }

        private string customCssCarousel = "tango";
        public string CustomCssCarousel { get { return customCssCarousel; } }

        private bool showImageWrapSetting;
        public bool ShowImageWrapSetting { get { return showImageWrapSetting; } }

        private bool noInvidualModule;
        public bool NoInvidualModule { get { return noInvidualModule; } }

        private bool useVerticalSetting;
        public bool UseVerticalSetting { get { return useVerticalSetting; } }

        private bool useRightToLeftSetting;
        public bool UseRightToLeftSetting { get { return useRightToLeftSetting; } }

        private int startSetting = 1;
        public int StartSetting { get { return startSetting; } }

        private int offsetSetting = 1;
        public int OffsetSetting { get { return offsetSetting; } }

        private int sizeSetting;
        public int SizeSetting { get { return sizeSetting; } }

        private int scrollItemSetting = 1;
        public int ScrollItemSetting { get { return scrollItemSetting; } }

        private int animationSetting = 200;
        public int AnimationSetting { get { return animationSetting; } }

        private string easingSetting = string.Empty;
        public string EasingSetting { get { return easingSetting; } }

        private int autoSetting;
        public int AutoSetting { get { return autoSetting; } }

        private string wrapSetting = "circular";
        public string WrapSetting { get { return wrapSetting; } }

        private string itemVisibleInCallbackSetting = string.Empty;
        public string ItemVisibleInCallbackSetting { get { return itemVisibleInCallbackSetting; } }

        private string itemVisibleOutCallbackSetting = string.Empty;
        public string ItemVisibleOutCallbackSetting { get { return itemVisibleOutCallbackSetting; } }

        private string moduleLoader = string.Empty;
        public string ModuleLoader { get { return moduleLoader; } }
    }
}